<% if proposal.rejected? || proposal.withdrawn? %>
  <div></div>
<% else %>
  <div id="proposal-<%= proposal.id %>-vote-button">
    <% if !current_user %>
      <% if current_settings.votes_blocked? %>
        <%= action_authorized_button_to :vote, proposal_proposal_vote_path(proposal_id: proposal, from_proposals_list:), resource: proposal, class: "column button light button--sc disabled", disabled: true do %>
          <%= t("decidim.proposals.proposals.vote_button.votes_blocked") %>
        <% end %>
      <% else %>
        <%= action_authorized_button_to :vote, proposal_proposal_vote_path(proposal_id: proposal, from_proposals_list:), resource: proposal, class: "column button light button--sc", data: { disable: true, "redirect-url": proposal_path(proposal) } do %>
          <%= t("decidim.proposals.proposals.vote_button.vote") %>
          <span><%= decidim_html_escape(present(proposal).title) %></span>
        <% end %>
      <% end %>
    <% else %>
      <% if proposal_voted_by_user?(proposal) %>
        <%= action_authorized_button_to(
          :vote,
          proposal_proposal_vote_path(proposal_id: proposal, from_proposals_list:),
          resource: proposal,
          method: :delete,
          remote: true,
          data: {
            disable: true,
            original: t("decidim.proposals.proposals.vote_button.already_voted"),
            replace: t("decidim.proposals.proposals.vote_button.already_voted_hover"),
            "redirect-url": proposal_path(proposal)
          },
          class: "column button light button--sc success",
          id: "vote_button-#{proposal.id}"
        ) do %>
          <%= icon("check-line", class: "icon--small", role: "img", "aria-hidden": true) %>
          <%= t("decidim.proposals.proposals.vote_button.already_voted") %>
          <span><%= decidim_html_escape(present(proposal).title) %></span>
        <% end %>
      <% else %>
        <% if proposal.maximum_votes_reached? && !proposal.can_accumulate_votes_beyond_threshold && current_component.participatory_space.can_participate?(current_user) %>
          <%= content_tag :span, t("decidim.proposals.proposals.vote_button.maximum_votes_reached"), class: "column button light button--sc disabled", disabled: true %>
        <% else %>
          <% if vote_limit_enabled? && remaining_votes_count_for_user == 0 %>
            <%= content_tag :span, t("decidim.proposals.proposals.vote_button.no_votes_remaining"), class: "column button light button--sc", disabled: true %>
          <% elsif current_settings.votes_blocked? || !current_component.participatory_space.can_participate?(current_user) %>
            <%= content_tag :span, t("decidim.proposals.proposals.vote_button.votes_blocked"), class: "column button light button--sc disabled", disabled: true %>
          <% else %>
            <%= action_authorized_button_to :vote, proposal_proposal_vote_path(proposal_id: proposal, from_proposals_list:), resource: proposal, remote: true, data: { disable: true, "redirect-url": proposal_path(proposal) }, class: "column button light button--sc" do %>
              <%= t("decidim.proposals.proposals.vote_button.vote") %>
              <span><%= decidim_html_escape(present(proposal).title) %></span>
            <% end %>
          <% end %>
        <% end %>
      <% end %>
    <% end %>
  </div>
<% end %>
